-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 107-ui-controls * prettier improvements
- Loading branch information
1 parent
75e5efb
commit 5212f59
Showing
22 changed files
with
108 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
bracketSpacing: false, | ||
bracketSameLine: true, | ||
bracketSameLine: false, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,47 @@ | ||
import React, {ReactNode, RefObject, useState} from 'react'; | ||
import {TouchableHighlight, ViewProps} from 'react-native'; | ||
import React, {ReactNode, RefObject} from 'react'; | ||
import { | ||
TouchableHighlight, | ||
Pressable, | ||
PressableProps, | ||
ViewStyle, | ||
StyleProp, | ||
} from 'react-native'; | ||
import {styles} from './styles'; | ||
|
||
interface ControlProps extends ViewProps { | ||
const focusedStyle = {opacity: 1}; | ||
const pressedStyle = {opacity: 0.25}; | ||
|
||
interface ControlProps extends PressableProps { | ||
children: ReactNode; | ||
callback?: () => void; | ||
controlRef?: RefObject<TouchableHighlight>; | ||
disabled?: boolean; | ||
style?: any; | ||
resetControlTimeout?: () => void; | ||
style?: StyleProp<ViewStyle>; | ||
} | ||
|
||
export const Control = ({ | ||
children, | ||
callback, | ||
controlRef, | ||
disabled, | ||
style = {}, | ||
onPress, | ||
resetControlTimeout, | ||
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} | ||
<Pressable | ||
ref={controlRef} | ||
underlayColor="transparent" | ||
activeOpacity={1} | ||
onPress={() => { | ||
callback && callback(); | ||
onPress={(evt) => { | ||
onPress?.(evt); | ||
resetControlTimeout?.(); | ||
}} | ||
style={[styles.control, style, focused && focusedStyle]} | ||
{...props}> | ||
style={({focused, pressed}) => [ | ||
styles.control, | ||
style, | ||
focused && focusedStyle, | ||
pressed && pressedStyle, | ||
]} | ||
{...props} | ||
> | ||
{children} | ||
</TouchableHighlight> | ||
</Pressable> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.