Skip to content

Commit 689e501

Browse files
committed
Fix dark mode hyperlink colors
1 parent dcdc5ca commit 689e501

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

NewArch/src/components/Controls.tsx

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
import React from 'react';
2-
import {Linking, Pressable, StyleSheet, Text} from 'react-native';
2+
import {Linking, Pressable, Text, useColorScheme} from 'react-native';
33

44
type HyperlinkProps = {
55
url: string;
66
text?: string;
77
};
88
function Hyperlink({url, text}: HyperlinkProps): JSX.Element {
9-
const styles = StyleSheet.create({
10-
hyperlinkIdle: {
11-
color: 'blue',
12-
textDecorationLine: 'underline',
13-
},
14-
hyperlinkHovering: {
15-
color: 'darkblue',
16-
textDecorationLine: 'underline',
17-
},
18-
hyperlinkPressing: {
19-
color: 'black',
20-
textDecorationLine: 'underline',
21-
},
22-
});
239
const [hovering, setHovering] = React.useState(false);
2410
const [pressing, setPressing] = React.useState(false);
11+
const colorScheme = useColorScheme();
12+
const isDark = colorScheme === 'dark';
2513

14+
const colors = {
15+
idle: isDark ? '#6CB6FF' : '#0066CC',
16+
hover: isDark ? '#8ECAFF' : '#004499',
17+
press: isDark ? '#A8D8FF' : '#003366',
18+
};
19+
20+
const linkColor = pressing ? colors.press : hovering ? colors.hover : colors.idle;
2621
let displayText = text ?? url;
2722

2823
return (
@@ -36,14 +31,7 @@ function Hyperlink({url, text}: HyperlinkProps): JSX.Element {
3631
onPressOut={() => setPressing(false)}
3732
onHoverIn={() => setHovering(true)}
3833
onHoverOut={() => setHovering(false)}>
39-
<Text
40-
style={
41-
pressing
42-
? styles.hyperlinkPressing
43-
: hovering
44-
? styles.hyperlinkHovering
45-
: styles.hyperlinkIdle
46-
}>
34+
<Text style={{color: linkColor, textDecorationLine: 'underline'}}>
4735
{displayText}
4836
</Text>
4937
</Pressable>

0 commit comments

Comments
 (0)