Implement dark mode for Android
This commit is contained in:
@@ -166,13 +166,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packagingOptions {
|
|
||||||
pickFirst "lib/armeabi-v7a/libc++_shared.so"
|
|
||||||
pickFirst "lib/arm64-v8a/libc++_shared.so"
|
|
||||||
pickFirst "lib/x86/libc++_shared.so"
|
|
||||||
pickFirst "lib/x86_64/libc++_shared.so"
|
|
||||||
}
|
|
||||||
|
|
||||||
// applicationVariants are e.g. debug, release
|
// applicationVariants are e.g. debug, release
|
||||||
applicationVariants.all { variant ->
|
applicationVariants.all { variant ->
|
||||||
variant.outputs.each { output ->
|
variant.outputs.each { output ->
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- Base application theme. -->
|
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
<item name="android:textColor">#000000</item>
|
<!-- <item name="android:textColor">#000000</item> -->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -36,7 +36,11 @@ static void InitializeFlipper(UIApplication *application) {
|
|||||||
moduleName:@"JellyfinAudioPlayer"
|
moduleName:@"JellyfinAudioPlayer"
|
||||||
initialProperties:nil];
|
initialProperties:nil];
|
||||||
|
|
||||||
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
|
if (@available(iOS 13.0, *)) {
|
||||||
|
rootView.backgroundColor = [UIColor systemBackgroundColor];
|
||||||
|
} else {
|
||||||
|
rootView.backgroundColor = [UIColor whiteColor];
|
||||||
|
}
|
||||||
|
|
||||||
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||||
UIViewController *rootViewController = [UIViewController new];
|
UIViewController *rootViewController = [UIViewController new];
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
DefaultTheme,
|
DefaultTheme,
|
||||||
DarkTheme,
|
DarkTheme,
|
||||||
} from '@react-navigation/native';
|
} from '@react-navigation/native';
|
||||||
import { colors } from './Colors';
|
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
isReady: boolean;
|
isReady: boolean;
|
||||||
@@ -55,8 +54,6 @@ export default class App extends Component<{}, State> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(colorScheme);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<PersistGate loading={null} persistor={persistedStore}>
|
<PersistGate loading={null} persistor={persistedStore}>
|
||||||
|
|||||||
26
src/components/Colors.android.tsx
Normal file
26
src/components/Colors.android.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { StyleSheet, PlatformColor } from 'react-native';
|
||||||
|
import { THEME_COLOR } from 'CONSTANTS';
|
||||||
|
|
||||||
|
export const colors = StyleSheet.create({
|
||||||
|
text: {
|
||||||
|
color: PlatformColor('?attr/colorOnBackground'),
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
backgroundColor: PlatformColor('?android:colorBackground'),
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
borderColor: '#88888844'
|
||||||
|
},
|
||||||
|
activeBackground: {
|
||||||
|
backgroundColor: `${THEME_COLOR}44`,
|
||||||
|
},
|
||||||
|
imageBackground: {
|
||||||
|
backgroundColor: PlatformColor('?attr/colorBackgroundFloating'),
|
||||||
|
},
|
||||||
|
modal: {
|
||||||
|
backgroundColor: PlatformColor('?attr/colorBackgroundFloating'),
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
backgroundColor: PlatformColor('?attr/colorBackgroundFloating'),
|
||||||
|
}
|
||||||
|
});
|
||||||
26
src/components/Colors.ios.tsx
Normal file
26
src/components/Colors.ios.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { StyleSheet, PlatformColor, DynamicColorIOS } from 'react-native';
|
||||||
|
import { THEME_COLOR } from 'CONSTANTS';
|
||||||
|
|
||||||
|
export const colors = StyleSheet.create({
|
||||||
|
text: {
|
||||||
|
color: PlatformColor('label'),
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
backgroundColor: PlatformColor('systemBackground'),
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
borderColor: PlatformColor('systemGray5Color'),
|
||||||
|
},
|
||||||
|
activeBackground: {
|
||||||
|
backgroundColor: DynamicColorIOS({ light: `${THEME_COLOR}16`, dark: `${THEME_COLOR}66` })
|
||||||
|
},
|
||||||
|
imageBackground: {
|
||||||
|
backgroundColor: PlatformColor('systemGray5Color')
|
||||||
|
},
|
||||||
|
modal: {
|
||||||
|
backgroundColor: DynamicColorIOS({ light: '#eeeeeeee', dark: '#222222ee' })
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
backgroundColor: PlatformColor('systemGray5Color'),
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
import { StyleSheet, PlatformColor, Platform, DynamicColorIOS } from 'react-native';
|
|
||||||
import { THEME_COLOR } from 'CONSTANTS';
|
|
||||||
|
|
||||||
export const colors = StyleSheet.create({
|
|
||||||
text: {
|
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
color: PlatformColor('label'),
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
color: PlatformColor('?android:attr/textColorPrimary'),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
view: {
|
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
backgroundColor: PlatformColor('systemBackground'),
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
backgroundColor: PlatformColor('?android:attr/backgroundTint'),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
border: {
|
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
borderColor: PlatformColor('systemGray5Color'),
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
borderColor: PlatformColor('?android:attr/backgroundTint'),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
activeBackground: {
|
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
backgroundColor: DynamicColorIOS({ light: `${THEME_COLOR}16`, dark: `${THEME_COLOR}66` })
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
backgroundColor: PlatformColor('?android:attr/backgroundTint'),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
imageBackground: {
|
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
backgroundColor: PlatformColor('systemGray5Color')
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
backgroundColor: PlatformColor('?android:attr/backgroundTint'),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
modal: {
|
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
backgroundColor: DynamicColorIOS({ light: '#eeeeeeee', dark: '#222222ee' })
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
backgroundColor: PlatformColor('?android:attr/backgroundTint'),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
input: {
|
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
backgroundColor: PlatformColor('systemGray5Color'),
|
|
||||||
color: PlatformColor('label'),
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
backgroundColor: PlatformColor('?android:attr/backgroundTint'),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -7,6 +7,7 @@ import ForwardIcon from 'assets/forwards.svg';
|
|||||||
import BackwardIcon from 'assets/backwards.svg';
|
import BackwardIcon from 'assets/backwards.svg';
|
||||||
import PlayIcon from 'assets/play.svg';
|
import PlayIcon from 'assets/play.svg';
|
||||||
import PauseIcon from 'assets/pause.svg';
|
import PauseIcon from 'assets/pause.svg';
|
||||||
|
import { useColorScheme } from 'react-native-appearance';
|
||||||
|
|
||||||
const BUTTON_SIZE = 40;
|
const BUTTON_SIZE = 40;
|
||||||
|
|
||||||
@@ -32,61 +33,64 @@ const Button = styled.View`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export default function MediaControls() {
|
export default function MediaControls() {
|
||||||
|
const scheme = useColorScheme();
|
||||||
|
const fill = scheme === 'dark' ? '#ffffff' : '#000000';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<Buttons>
|
<Buttons>
|
||||||
<Button>
|
<Button>
|
||||||
<PreviousButton />
|
<PreviousButton fill={fill} />
|
||||||
</Button>
|
</Button>
|
||||||
<MainButton />
|
<MainButton fill={fill} />
|
||||||
<Button>
|
<Button>
|
||||||
<NextButton />
|
<NextButton fill={fill} />
|
||||||
</Button>
|
</Button>
|
||||||
</Buttons>
|
</Buttons>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PreviousButton() {
|
export function PreviousButton({ fill }: { fill: string }) {
|
||||||
const hasQueue = useHasQueue();
|
const hasQueue = useHasQueue();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={previous} disabled={!hasQueue} style={{ opacity: hasQueue ? 1 : 0.5 }}>
|
<TouchableOpacity onPress={previous} disabled={!hasQueue} style={{ opacity: hasQueue ? 1 : 0.5 }}>
|
||||||
<BackwardIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill="#000" />
|
<BackwardIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill={fill} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NextButton() {
|
export function NextButton({ fill }: { fill: string }) {
|
||||||
const hasQueue = useHasQueue();
|
const hasQueue = useHasQueue();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={next} disabled={!hasQueue} style={{ opacity: hasQueue ? 1 : 0.5 }}>
|
<TouchableOpacity onPress={next} disabled={!hasQueue} style={{ opacity: hasQueue ? 1 : 0.5 }}>
|
||||||
<ForwardIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill="#000" />
|
<ForwardIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill={fill} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MainButton() {
|
export function MainButton({ fill }: { fill: string }) {
|
||||||
const state = usePlaybackState();
|
const state = usePlaybackState();
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case STATE_PLAYING:
|
case STATE_PLAYING:
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={pause}>
|
<TouchableOpacity onPress={pause}>
|
||||||
<PauseIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill="#000" />
|
<PauseIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill={fill} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
case STATE_PAUSED:
|
case STATE_PAUSED:
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={play}>
|
<TouchableOpacity onPress={play}>
|
||||||
<PlayIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill="#000" />
|
<PlayIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill={fill} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={pause} disabled>
|
<TouchableOpacity onPress={pause} disabled>
|
||||||
<PauseIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill="#000" />
|
<PauseIcon width={BUTTON_SIZE} height={BUTTON_SIZE} fill={fill} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,20 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DynamicColorIOS, StyleSheet, ScrollView, Platform, PlatformColor } from 'react-native';
|
import { StyleSheet, ScrollView } from 'react-native';
|
||||||
import MediaControls from './components/MediaControls';
|
import MediaControls from './components/MediaControls';
|
||||||
import ProgressBar from './components/ProgressBar';
|
import ProgressBar from './components/ProgressBar';
|
||||||
import NowPlaying from './components/NowPlaying';
|
import NowPlaying from './components/NowPlaying';
|
||||||
import Queue from './components/Queue';
|
import Queue from './components/Queue';
|
||||||
|
import { colors } from 'components/Colors';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
outer: {
|
outer: colors.view,
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
color: PlatformColor('label'),
|
|
||||||
backgroundColor: PlatformColor('systemBackground'),
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
color: PlatformColor('?android:attr/textColorPrimary'),
|
|
||||||
backgroundColor: PlatformColor('?android:attr/backgroundTint'),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
inner: {
|
inner: {
|
||||||
padding: 25,
|
padding: 25,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(JSON.stringify(styles));
|
||||||
|
|
||||||
export default function Player() {
|
export default function Player() {
|
||||||
return (
|
return (
|
||||||
<ScrollView contentContainerStyle={styles.inner} style={styles.outer}>
|
<ScrollView contentContainerStyle={styles.inner} style={styles.outer}>
|
||||||
|
|||||||
Reference in New Issue
Block a user