Skip to content

Commit

Permalink
[+] Invert the colors of focused for play/pause
Browse files Browse the repository at this point in the history
  • Loading branch information
Elyse Segebart authored and LunatiqueCoder committed Feb 13, 2023
1 parent b4eb614 commit 27117ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/Control.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {ReactNode, RefObject} from 'react';
import React, {ReactNode, RefObject, useState} from 'react';
import {TouchableHighlight, ViewProps} from 'react-native';
import {styles} from './styles';

Expand All @@ -19,16 +19,25 @@ export const Control = ({
style = {},
...props
}: ControlProps) => {
const [focused, setFocused] = useState(false);

const setFocusedState = () => setFocused(true);
const cancelFocusedState = () => setFocused(false);

const focusedStyle = focused ? {opacity: 1} : {};

return (
<TouchableHighlight
onFocus={setFocusedState}
onBlur={cancelFocusedState}
disabled={disabled}
ref={controlRef}
underlayColor="transparent"
activeOpacity={0.3}
activeOpacity={1}
onPress={() => {
callback && callback();
}}
style={[styles.control, style]}
style={[styles.control, focused && focusedStyle]}
{...props}>
{children}
</TouchableHighlight>
Expand Down
1 change: 1 addition & 0 deletions src/components/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const styles = StyleSheet.create({
},
control: {
padding: 16,
opacity: 0.6,
},
text: {
backgroundColor: 'transparent',
Expand Down

0 comments on commit 27117ac

Please sign in to comment.