1
1
import React from 'react' ;
2
2
import styled from '@emotion/native' ;
3
- import { ViewStyle } from 'react-native' ;
3
+ import { StyleProp , View , ViewStyle } from 'react-native' ;
4
4
5
5
interface Props {
6
6
onPress : ( ) => void ;
7
- style ?: ViewStyle ;
7
+ style ?: StyleProp < ViewStyle > ;
8
8
}
9
9
10
10
const Touchable = styled . TouchableOpacity ( {
@@ -15,11 +15,46 @@ const Touchable = styled.TouchableOpacity({
15
15
zIndex : 100 ,
16
16
} ) ;
17
17
18
- const HideIcon = styled . Text ( ( { theme } ) => ( {
19
- fontSize : 14 ,
20
- color : theme . buttonTextColor || '#999999' ,
18
+ const HIDE_ICON_SIZE = 14 ;
19
+ const HIDE_ICON_BORDER_WIDTH = 1 ;
20
+
21
+ const Inner = styled . View ( ( { theme } ) => ( {
22
+ position : 'absolute' ,
23
+ top : 0 ,
24
+ left : 0 ,
25
+ width : HIDE_ICON_SIZE ,
26
+ height : HIDE_ICON_SIZE ,
27
+ borderRadius : HIDE_ICON_BORDER_WIDTH ,
28
+ overflow : 'hidden' ,
29
+ borderColor : theme . buttonTextColor || '#999999' ,
30
+ borderWidth : HIDE_ICON_BORDER_WIDTH * 2 ,
21
31
} ) ) ;
22
32
33
+ const Outer = styled . View ( {
34
+ position : 'absolute' ,
35
+ top : 0 ,
36
+ left : 0 ,
37
+ width : HIDE_ICON_SIZE ,
38
+ height : HIDE_ICON_SIZE ,
39
+ borderRadius : HIDE_ICON_BORDER_WIDTH ,
40
+ overflow : 'hidden' ,
41
+ borderColor : 'white' ,
42
+ borderWidth : HIDE_ICON_BORDER_WIDTH ,
43
+ } ) ;
44
+
45
+ const hideIconStyles = {
46
+ width : HIDE_ICON_SIZE ,
47
+ height : HIDE_ICON_SIZE ,
48
+ marginRight : 4 ,
49
+ } ;
50
+
51
+ const HideIcon = ( ) => (
52
+ < View style = { hideIconStyles } >
53
+ < Inner />
54
+ < Outer />
55
+ </ View >
56
+ ) ;
57
+
23
58
const VisibilityButton = ( { onPress, style } : Props ) => (
24
59
< Touchable
25
60
onPress = { onPress }
@@ -28,7 +63,7 @@ const VisibilityButton = ({ onPress, style }: Props) => (
28
63
accessibilityLabel = "Storybook.OnDeviceUI.toggleUI"
29
64
hitSlop = { { top : 5 , left : 5 , bottom : 5 , right : 5 } }
30
65
>
31
- < HideIcon > â–¡ </ HideIcon >
66
+ < HideIcon / >
32
67
</ Touchable >
33
68
) ;
34
69
export default React . memo ( VisibilityButton ) ;
0 commit comments